package com.ruoyi.yf.tool.barcode;

import java.util.HashMap;
import java.util.HashSet;

public class TestMain {


    public static void main(String[] args) {
        Thread1 thread1 = new Thread1("线程1:");
        Thread1 thread2 = new Thread1("线程2:");
        Thread1 thread3 = new Thread1("线程3:");
        Thread1 thread4 = new Thread1("线程4:");
        Thread1 thread5 = new Thread1("线程5:");
        Thread1 thread6 = new Thread1("线程6:");

        thread1.start();
        thread2.start();
        thread3.start();
        thread4.start();
        thread5.start();
        thread6.start();
    }
}


class Thread1 extends Thread {

    public static HashMap codeList = new HashMap();

    public Thread1(String name) {
        super(name);// 给线程名字赋值
    }


    public synchronized void generate() throws InterruptedException {
        while (true) {
            String code = Rules.br();
            int c = codeList.size();
            codeList.put("1212121", getName());
            if (codeList.size() - 1 == c) {
                System.out.println("-----------------------ERR:" + codeList.get(code) + code + "：" + codeList.size());
                break;
            }
            System.out.println(codeList.get(code) + code + "：" + codeList.size());
//            System.out.println(getName() + "第" + "次相同,存储：" + codeList.size() + "条，值为：" + code + "，尾部随机数为 " + code.substring(10, 18) + " " + codeList.get(code));
//                startTest();

//            System.out.println(getName() + "i=" + i + "<>list:" + codeList.size() + "条<>" + code);
        }
    }

    @Override
    public void run() {
        try {
            generate();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
